'use strict';

let port = 3000;
const Koa = require('koa');
const app = new Koa();

const bodyparser = require('koa-bodyparser');
const cors = require('koa2-cors');
const regRoute = require('./router');
const {db} = require('./db');


app.use(cors({
    'maxAge': 5
}));
app.use(bodyparser()); 

app.use(async (ctx, next) => {
    console.log(`${ctx.request.method}: ${ctx.request.url}`);
    await next();
})

app.use(regRoute());

app.listen(port);
console.log(`Server is running at http://localhost:${port}`);